//
//  BaseTableViewController.swift
//  Zayl--weibo
//
//  Created by 张玉 on 15/9/6.
//  Copyright © 2015年 ZY. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    var userLogin = false
    //访客登录视图
    var visitorView:VisitorLoginView?
    
    override func loadView() {
        userLogin ? super.loadView():setupVisirorView()
        
    }
    //设置访客视图
    private func setupVisirorView() {
        visitorView = VisitorLoginView()
        //访客登录视图 成为代理
        visitorView?.delegata = self
        
        view  = visitorView
        //导航栏
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
        
    }
    //MARK - VisitorLoginViewDelegate  代理方法的实现
    func  visitorLoginViewWillLogin() {
        //设置'登录'按钮 实现方法跳转控制器
        let nav = UINavigationController(rootViewController: OAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
        
    }
    func visitorLoginViewWillRegister() {
        print("注册了")
    }
}
